package com.winning.devops.batch.processor.ch01;

import com.winning.devops.batch.processor.ch01.domain.Customer;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.stereotype.Component;

/**
 * ID数据处理
 *
 * @author chensj
 * @date 2020-03-07 21:30
 */
@Component("idFilterItemProcessor")
public class IdFilterItemProcessor implements ItemProcessor<Customer, Customer> {
    @Override
    public Customer process(Customer item) throws Exception {
        if (item.getId() % 2 == 0) {
            item.setId(item.getId() + 200);
        } else {
            item.setId(item.getId() + 100);
        }

        //if (item.getId() % 2 == 0) {
        //    return  item;
        //} else {
        //    // 返回null 表示把数据过滤掉
        //    return  null;
        //}
        return item;
    }
}
